//
//  HPAddCustomerViewController.m
//  HappyPenguin
//
//  Created by zhuangyihang on 1/11/16.
//  Copyright © 2016 zhuangyihang. All rights reserved.
//

#import "HPAddCustomerViewController.h"

static const CGFloat kInfoPanelHeightRatio = 0.5;
static const NSInteger kPortraitViewWidth = 90;

@interface HPAddCustomerViewController ()

@end

@implementation HPAddCustomerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupFullContentView];
    [self addBackButton:nil];
    
    [self setBaseNavigationBarTitle:@"新增会员"];
    [self.baseRightButton setTitle:@"保存" forState:UIControlStateNormal];
    
    [self setupUI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark - Private
- (void)setupUI{

    [self setupInfoPanel];
}

- (void)setupInfoPanel{
    UIImageView *panel = [UIImageView new];
    [self.baseContentView addSubview:panel];
    [panel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.centerX.equalTo(self.baseContentView);
        make.height.equalTo(panel.mas_width).multipliedBy(kInfoPanelHeightRatio);
    }];
    panel.userInteractionEnabled = YES;
    panel.image = [UIImage imageNamed:@"Customer_PanelBackGround"];
    panel.contentMode = UIViewContentModeScaleAspectFill;
    
    UIImageView *portrait = [UIImageView new];
    [panel addSubview:portrait];
    [portrait mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(kPortraitViewWidth);
        make.centerY.equalTo(panel).offset((IAppNavigationBarHeight+IAppStatusBarHeight)/2);
        make.centerX.equalTo(panel);
    }];
    portrait.layer.borderColor = [UIColor whiteColor].CGColor;
    portrait.layer.borderWidth = 3;
    portrait.layer.cornerRadius = kPortraitViewWidth/2;
    portrait.clipsToBounds = YES;
    [portrait sd_setImageWithURL:[NSURL URLWithString:@"https://pic4.zhimg.com/8d6a36a3f_m.jpg"]];
}
@end
